﻿function initialize() {
    var stockholm = new google.maps.LatLng(59.32522, 18.07002);
    var parliament = new google.maps.LatLng(59.327383, 18.06747);
    var map;
    var marker;
    var mapOptions = {
        zoom: 13,
        center: stockholm
    };

    map = new google.maps.Map(document.getElementById('map-canvas'),
            mapOptions);

    marker = new google.maps.Marker({
        map: map,
        draggable: true,
        animation: google.maps.Animation.DROP,
        position: parliament
    });
    google.maps.event.addListener(marker, 'click', function () {
        if (marker.getAnimation() != null) {
            marker.setAnimation(null);
        } else {
            marker.setAnimation(google.maps.Animation.BOUNCE);
        }
    });
}

$(document).ready(function () {
    initialize();

    $('.photoimg').click(function () {
        var imgArray = new Array(
                          "/Images/image1.png",
                          "/Images/image2.png",
                          "/Images/image3.png",
                          "/Images/image4.png",
                          "/Images/q3.jpg"
                       );
        var img = $(this);
        $('#modalDiv img').attr("src", img.attr("src"));
        //$('#modalDiv img').attr("src", imgArray[numImages-1]);
        $('#modalBackground').show();
        $('#modalDiv').show();
        var top = Math.max($(window).height() / 2 - $('#modalDiv')[0].offsetHeight / 2, 0);
        var left = Math.max($(window).width() / 2 - $('#modalDiv')[0].offsetWidth / 2, 0);
        $('#modalDiv').css('top', top + "px");
        $('#modalDiv').css('left', left + "px");
        //$('#modalDiv').css('width', 1200 + "px");
        //$('#modalDiv').css('text-align', "center");


        var numImages = 5;
        var curImage = imgArray.indexOf(img.attr("src")) + 1;
        //var index = imageList.indexOf(200);
        $('#imgnext').click(function () {
            curImage = curImage + 1;
            if (curImage > numImages)
            { curImage = 1; }
            if (curImage == 0)
            { curImage = numImages; }

            $('#modalDiv img').attr("src", imgArray[curImage - 1]);
        });
        $('#imgpre').click(function () {
            curImage = curImage - 1;
            if (curImage > numImages)
            { curImage = 1; }
            if (curImage == 0)
            { curImage = numImages; }

            $('#modalDiv img').attr("src", imgArray[curImage - 1]);



        });
    });

    $('#thoat').click(function () {
        $('#modalBackground').hide();
        $('#modalDiv').hide();
    });

    $('#modalBackground').click(function () {
        $('#modalBackground').hide();
        $('#modalDiv').hide();
    });

});